<?php
/*
 * description：
 * author：wh
 * email：
 * createTime：{2020/5/29} {18:09} 
 */

namespace extend\model;


use think\Db;

class AutoCodeFieldsModel extends BaseModel
{
    static $self_table = 'web_auto_code_fields';

    static function getFieldsByDbname($dbname){
        $auto_obj = Db::name(self::$self_table);
        $auto_obj->order('sort DESC')->where(['is_deleted'=>0, 'dbname'=>$dbname]);
        return $auto_obj->select();
    }

    static function getSearchFieldsByDbname($dbname){
        $auto_obj = Db::name(self::$self_table);
        $auto_obj->order('sort DESC')->where(['is_deleted'=>0, 'is_search'=>1, 'dbname'=>$dbname]);
        return $auto_obj->select();
    }

    static function getFieldById(int $id){
        $auto_obj = Db::name(self::$self_table);
        $auto_obj->where(['is_deleted'=>0, 'id'=>$id]);
        return $auto_obj->find();
    }

    static function getByFieldName(string $fields_name){
        $auto_obj = Db::name(self::$self_table);
        $auto_obj->where(['is_deleted'=>0, 'fields_name'=>$fields_name]);
        return $auto_obj->find();
    }


}